<?php
if(!check_manager_login()) exit('无权查看，请登录!');
require_once(MODEL_PATH.DS.'Attribute.php');
$Attribute = new Attribute();
$id = isset($_GET['attr_id'])?(int)$_GET['attr_id']:'';

if(check_post()){
	$attr_id = trim($_POST['attr_id']);
	$name = trim($_POST['name']);
	if(empty($name)){
		redirect('index.php?mod=attribute&act=list','属性名称不能为空!');
	}
	if($attr_id){
		$result = $Attribute->updateAttributeById($attr_id,$name);
		$msg = "更新成功!";
	}else{
		$result = $Attribute->addAttribute($name);
		$msg = '添加成功！';
	}
	if($result){
		redirect('index.php?mod=attribute&act=list',$msg);
	}
}

$list = $Attribute->getAttributeList();
if($id){
   $attr_arr = $Attribute->getAttributeById($id);
}
include load_tpl('attribute_list');
?>